use egui::Vec2;
use QcCore::ecs::components::camera::Camera;
use QcUI::core::context::UiContext;

use crate::inspector::{ComponentState, InspectorContext, InspectorTrait};



impl InspectorTrait for Camera {
    fn inspector(&mut self, ctx: &mut InspectorContext, state: &mut ComponentState) {
        egui::CollapsingHeader::new("Camera")
            .default_open(true)
            .show(ctx.ui, |ui| {
                ui.group(|ui| {
                    ui.set_min_width(ui.available_width() - 5.);
                    egui::Grid::new("Camera")
                        .num_columns(2)
                        .min_col_width(70.)
                        .spacing(Vec2::new(10., 10.))
                        .show(ui, |ui| {
                            ui.label("Fov");
                            ui.horizontal(|ui| {
                                let mut size = ui.spacing().interact_size;
                                size.x = ui.available_width();

                                ui.add_sized(size, egui::DragValue::new(&mut self.fov).speed(0.01));
                            });
                            ui.end_row();

                            ui.label("Near");
                            ui.horizontal(|ui| {
                                let mut size = ui.spacing().interact_size;
                                size.x = ui.available_width();

                                ui.add_sized(
                                    size,
                                    egui::DragValue::new(&mut self.near).speed(0.01),
                                );
                            });
                            ui.end_row();

                            ui.label("Far");
                            ui.horizontal(|ui| {
                                let mut size = ui.spacing().interact_size;
                                size.x = ui.available_width();

                                ui.add_sized(size, egui::DragValue::new(&mut self.far).speed(0.01));
                            });
                            ui.end_row();

                            ui.label("Aspect");
                            ui.horizontal(|ui| {
                                let mut size = ui.spacing().interact_size;
                                size.x = ui.available_width();

                                ui.add_sized(
                                    size,
                                    egui::DragValue::new(&mut self.aspect).speed(0.01),
                                );
                            });
                            ui.end_row();
                        })
                });
            });
    }
}
